<?php
import('Cache.~');
/**
 * IndexController
 *
 * @package
 * @author darche
 * @copyright Copyright (c) 2009
 * @version $Id$
 * @access public
 */
class PhotosController extends Hoa_Controller_Action_Standard {

	/**
	 * IndexController::IndexAction()
	 *
	 * @return
	 */
	public function IndexAction(){
		# Inclusion des fichier JS + CSS
		$this->head->addCssFile($this->config->rep->cssFileForJs.'/jquery.lightbox-0.5.css');
		$this->head->addCssFile($this->config->rep->cssFile.'/galery.css');
		$this->head->addJsFile($this->config->rep->jsFileLib.'/jquery.easing.1.3.js');
		$this->head->addJsFile($this->config->rep->jsFileLib.'/jquery.galleryview-1.1.js');
		$this->head->addJsFile($this->config->rep->jsFileLib.'/jquery.timers-1.1.2.js');
		$this->head->addJsFile($this->config->rep->jsFile.'/gallery.js');

		$script = '
			$(document).ready(function(){

				$(\'.pic a\').lightBox({

					imageLoading: \''.$this->config->rep->cssFileForJs.'/images/loading.gif\',
					imageBtnClose: \''.$this->config->rep->cssFileForJs.'/images/close.gif\',
					imageBtnPrev: \''.$this->config->rep->cssFileForJs.'/images/prev.gif\',
					imageBtnNext: \''.$this->config->rep->cssFileForJs.'/images/next.gif\'

				});

			});
		';
		$this->head->addJsScript($script);

		# Gestion du cache
		$frontendOptions = array(
			'lifetime' => 600
		);
		$backendOptions = array(
			'cache_directory' => $this->config->rep->cacheDirectory.'/'
		);
		$cache = Hoa_Cache::factory('Class', 'File', $frontendOptions, $backendOptions);
		$cache->setObject('photosModel');
		$this->view->pictures = $cache->showAllPhotos($this->config->rep->imgFile.'/gallery');
		$this->view->mini = $cache->showAllMiniature($this->config->rep->imgFile.'/gallery/mini');


		$this->view->config = $this->config;
		$this->view->titre = 'Photos';
		$this->view->head 	= $this->head;
		echo $this->view->render();
	}

}